include('JS/Canvas.js');

function onMouseMove(e) 
{
  var posx = e.pageX - this.offsetLeft;;
  var posy = e.pageY - this.offsetTop;

    
  document.getElementById('x').value= posx;
  document.getElementById('y').value = posy;
}

function test(name)
{  
  this.canvas = new Canvas_Draw(name);

  //this.canvas.element.addEventListener('mouseover',onMouseMove,true);
  this.canvas.element.addEventListener('mousemove',onMouseMove,true);
  
  this.canvas.context.clearRect(0,0,640,480);
  
  var red = this.canvas.addColour('Red',255,0,0);
  this.canvas.drawRect(red,0,0,100,100);
  
  var image = this.canvas.addImage('cross','Images/trans.png');
  this.canvas.drawImage(image,100,0,100,100);

var compositeTypes = [
  'source-over','source-in','source-out','source-atop',
  'destination-over','destination-in','destination-out','destination-atop',
  'lighter','darker','copy','xor'
];


  this.canvas.context.globalCompositeOperation = compositeTypes[3];

  var blue = this.canvas.addColour('blue',0,0,255);
  this.canvas.drawRect(blue,100,0,100,100);
  
  this.canvas.context.globalCompositeOperation = compositeTypes[0];
  
    var red = this.canvas.addColour('Red',255,0,0);
  this.canvas.drawRect(red,200,0,100,100);
}


function init(name)
{
  try {
    //test(name);
    alert('Worked!');
  } catch(e)
  {
    alert(e);
  }
  

}
